测试链接：https://leetcode.cn/problems/product-of-array-except-self/
class Solution {
public:
    vector<int> productExceptSelf(vector<int>& nums) {
        int len = nums.size();
        vector<int> f(nums.size(), 1), g(len, 1);
        for(int i = 1; i < len; i++)
        {
            f[i] = f[i-1]*nums[i-1];
        }
    for(auto & x : f)
    {
        cout << x << " ";
    }
cout <<endl;
    for(int i = len - 2; i >= 0; i--)
    {
        g[i] = g[i+1]*nums[i+1];
    }
     for(auto & x : g)
    {
        cout << x << " ";
    }   
        int temp = 1;
        for(int i = len-2; i >= 0;i--)
        {
            temp *= nums[i+1];
            f[i] *= temp;          
        }
        return f;
    }
};